﻿<?php echo $this->Html->css('product'); ?>
<?php echo $this->Html->css('form'); ?>
<?php echo $this->Html->script('ckeditor/ckeditor'); ?>
<?php echo $this->Html->script('modify_image'); ?>

<?php
$myControl = $this->params["controller"];
$myAction = $this->params["action"];

$cont = Inflector::classify($myControl);
$act = Inflector::camelize($myAction);
?>
<?php echo $this->Form->create('Product',array('url'=>'/products/add','id' => "{$cont}{$act}Form",'enctype' => 'multipart/form-data'));?>

<div class="contentMain">
<div class="grayBox">
<div class="form_wrapper remove_top_border">
		<div class="title">Add Product</div>
			<ul class="addBox">
				<li>
					<span class="titleName"><label>Name</label></span>
					<?php 
					echo $this->Form->text('name', array(
						'style' => 'width: 300px',
						'placeholder' => 'Display name for product',
						'required' => 'required'));
					echo '&nbsp;';
					echo $this->Form->error('name',array('class'=>'error-message'));
					?>
				</li>
				<li>
					<span class="titleName"><label>Category</label></span>
					<?php
					echo $form->input('category_id', array(
						'options' => $categories,
						'label' => false,
						'div' => false
						));
					?>
					<div class="fontSmall">
						If the product doesn't belong to any given category, you can add a category 
						<?=$html->link('here', '/categories/add')?>
					</div>
				</li>
				<li>
					<span class="titleName"><label>Manufacturer</label></span>
					<?php
					echo $form->input('manufacturer_id', array(
						'options' => $manufacturers,
						'label' => false,
						'div' => false
						));
					?>
					<div class="fontSmall">
						If the product's manufacturer isn't in the given list, you can add a manufacturer <?=$html->link('here', '/manufacturers/add')?>
					</div>
				</li>
				<li>
					<span class="titleName"><label>Thumbnail for product</label></span>
								<?php 
									echo $this->Form->file('image_form', array('class'=>'inputFile', 'onchange' => 'modify_image(this, "productThumbnail1")', 'required' => 'required'));
									echo $this->Form->error('image_form',array('class'=>'error-message'));
								?>
								<div class="fontSmall"> File type JPG, PNG or GIF only. Maximum of 800kb. Recommended dimension is 210 x 150.</div>
											
				</li>
				<li>
					<img id="productThumbnail1" style="margin-left:240px;width:210px"></img>
				</li>
				<li style="margin-top:25px">
						<span class="titleName">
							
							<label>Description</label>
						</span>
						<div class="editorBox">
								<?php
									echo $this->Form->textarea('description', array('id'=>'description'));
									echo $this->Form->error('description',array('class'=>'error-message'));
								?>
						</div>
				</li>	
			</ul>
			<?=$this->Form->button(__('Save and publish', true), array(
				'class' => 'btnYellow01 btn', 'type' => 'submit', 'style'=>'display:none', 'id'=>'save_publish','name'=>'savePublish')); ?>
			<div class="button_container" style="float:left;margin-left: 25%">
				<a class="btnYellow01 btn" href="#" onclick="$('#save_publish').click(); return false;"><span class="btnBg">Add Product</span></a>
				<a href="<?=$this->webroot?>" class="btnYellow01 btn"><span class="btnBg">Cancel</span></a>
			</div>
</div>
</div>
</div>
		
			

<?php
echo $this->Form->end();
?>
<script>
CKEDITOR.replace( 'description', {height: 300});
CKEDITOR.on("instanceReady", function(){
    $('#cke_description').css('margin-left', '25.5%').css('margin-top', '-20px');
});
</script>
